/**
 * Created by bing on 2019/3/27.
 */
package com.wxb.hello.java.feature;

import java.util.Optional;

/**
 * describe:
 *
 * @author : wxbing000@gmail.com
 * @version : v1.0
 * @date : 2019-03-27 18:50
 */
public class OptionalDemo {

	public static void main(String[] args) {
		Optional<String> op1 = Optional.of("Hello");
		System.out.println(op1.isPresent());
		System.out.println(op1.get());


		Optional<String> op2 = Optional.ofNullable(null);
		System.out.println(op2.isPresent());

		Optional<String> op3 = Optional.of("Hello");
		op3.ifPresent((s) -> {
			System.out.println(s); // 输出 Hello
		});


		Optional.of("ssss").ifPresent((s) ->{
			System.out.println(s);
		});

		Optional.of("ssss").orElse("sdf");


	}

}
